package com.usefullc.system.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.system.domain.Feedback;
import com.usefullc.system.mapper.FeedbackMapper;
import com.usefullc.system.param.FeedbackSubmitParam;
import com.usefullc.system.query.FeedbackQuery;

/**
 * @author: Sampson
 * @date: 2022-03-27 15:29
 */
@org.springframework.stereotype.Service
public class FeedbackService extends AbstractBizService<FeedbackMapper, Feedback, FeedbackQuery> {

//    @Override
//    public List<Predicate> getPredicates(Root<Feedback> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder, BaseQuery q) {
//        FeedbackQuery thisQuery = (FeedbackQuery) q;
//        List<Predicate> predicates = new ArrayList<>();
//        if (thisQuery.getDelState() != null) {
//            predicates.add(criteriaBuilder.equal(root.get("delState"), thisQuery.getDelState()));
//        }
//        if (thisQuery.getStatus() != null) {
//            predicates.add(criteriaBuilder.equal(root.get("status"), thisQuery.getStatus()));
//        }
//        if (StringUtils.isNotEmpty(thisQuery.getCode())) {
//            predicates.add(criteriaBuilder.equal(root.get("code"), thisQuery.getCode()));
//        }
//        if (StringUtils.isNotEmpty(thisQuery.getMachineId())) {
//            predicates.add(criteriaBuilder.equal(root.get("machineId"), thisQuery.getMachineId()));
//        }
//
//        return predicates;
//    }


    @Override
    protected QueryWrapper<Feedback> getQueryWrapper(FeedbackQuery query) {
        QueryWrapper<Feedback> queryWrapper = super.getQueryWrapper(query);
        return queryWrapper;
    }

    public void submit(FeedbackSubmitParam param){
        Feedback feedback = BeanUtils.beanCopy(param, Feedback.class);
        this.save(feedback);

    }

}
